package com.gxa.service.baoBiaoService.impl;

import com.gxa.common.R;
import com.gxa.mapper.baobiaomapper.XiaoShouBaoBiaoMapper;
import com.gxa.service.baoBiaoService.XiaoShouBaoBiaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Service
public class XiaoShouBaoBiaoServiceImpl implements XiaoShouBaoBiaoService {

    @Autowired
    private XiaoShouBaoBiaoMapper xiaoShouBaoBiaoMapper;

    @Override
    public R selectXiaoShouMingXi(String startTime, String endTime, String keHuId, String shangPinId, String cangKuId, String zhiYuanId) {
        R r=new R();

        List list = new ArrayList();


        list=xiaoShouBaoBiaoMapper.selectXiaoShouMingXi(startTime, endTime ,  keHuId, shangPinId, cangKuId,zhiYuanId);


        r.setCode(200);
        r.setMsg("销售明细查询成功！");
        r.setData(list);

        return r;
    }

    @Override
    public R selectWangLaiDanWeiQianKuan(String chaXunNeiRong, String keHuCheck, String gongYingShangCheck) {
        R r=new R();

        HashMap<Object, Object> map = new HashMap<>();

        if (("0".equals(keHuCheck)&&"0".equals(gongYingShangCheck))||("1".equals(keHuCheck)&&"1".equals(gongYingShangCheck))){
            map.put("客户",xiaoShouBaoBiaoMapper.selectWangLaiDanWeiQianKuanForKeHu(chaXunNeiRong));
            map.put("供应商",xiaoShouBaoBiaoMapper.selectWangLaiDanWeiQianKuanForGongYingShang(chaXunNeiRong));
        }else if("0".equals(keHuCheck)&&"1".equals(gongYingShangCheck)){
            map.put("供应商",xiaoShouBaoBiaoMapper.selectWangLaiDanWeiQianKuanForGongYingShang(chaXunNeiRong));
        }else if("1".equals(keHuCheck)&&"0".equals(gongYingShangCheck)) {
            map.put("客户",xiaoShouBaoBiaoMapper.selectWangLaiDanWeiQianKuanForKeHu(chaXunNeiRong));
        }else {
            r.setCode(200);
            r.setMsg("查询失败！");
            return r;
        }
        r.setCode(200);
        r.setMsg("往来单位欠款表查询成功！");
        r.setData(map);
        return r;
    }
}
